package org.hhh.basic.interceprot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration//申明为spring的配置类
public class WebConfigurer  implements WebMvcConfigurer{
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//拦截所以
                .excludePathPatterns("/login/**",//选择放行的资源
                        "/user/phone/register",
                        "/shop/settlement",
                        "/fastDfs/**",
                        "/verifycode/**",
                        "/notify", //支付宝支付成功之后的异步回调地址
                        "/swagger-resources/**","/webjars/**","/v2/**","/swagger-ui.html/**");

    }
}
